package com.smasher.dialog.alert;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog.Builder;
import androidx.fragment.app.DialogFragment;

import com.smasher.dialog.BaseDialogFragment;
import com.smasher.dialog.R;


/**
 * 确认
 * @author HXZ_Android
 */
public class ConfirmDialog extends BaseDialogFragment {

    protected CharSequence title = "";
    protected CharSequence content = "";
    protected int confirmString = R.string.app_ok;
    protected int cancelString = R.string.app_cancel;


    @Override
    public void onAttach(@NonNull Context context) {
        super.onAttach(context);
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setStyle(DialogFragment.STYLE_NO_FRAME, 0);
    }

    @NonNull
    @Override
    public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
        Builder builder = new Builder(requireContext())
                .setTitle(title)
                .setMessage(content)
                .setPositiveButton(confirmString, mPositiveListener)
                .setNegativeButton(cancelString, mNegativeListener);
        return builder.create();
    }

    public void setTitle(CharSequence title) {
        this.title = title;
    }

    public void setContent(CharSequence content) {
        this.content = content;
    }

    public void setConfirmString(int confirmString) {
        this.confirmString = confirmString;
    }

    public void setCancelString(int cancelString) {
        this.cancelString = cancelString;
    }

    private DialogInterface.OnClickListener mPositiveListener;

    public void setPositiveListener(DialogInterface.OnClickListener listener) {
        mPositiveListener = listener;
    }

    private DialogInterface.OnClickListener mNegativeListener;

    public void setNegativeListener(DialogInterface.OnClickListener listener) {
        mNegativeListener = listener;
    }


    @Override
    protected void initData() {

    }

    @Override
    protected void initView() {

    }
}
